import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;


/**
 * @author soffo
 *
 */
public class RentalFileManager {

	File file;
	BufferedReader bufferedReader;
	BufferedWriter bufferedWriter;
	PrintWriter printWriter;
	FileOutputStream fos;
	ObjectOutputStream oos;

	public RentalFileManager() {
		// TODO Auto-generated constructor stub
	}

	public void openFile() {
		file = new File("videoStore.txt");

	}

	// public void writeToFile(HashMap<Integer,Object> videos) throws
	// IOException
	public void writeToFile(ArrayList<RentalModel> rentalModels)
			throws IOException {

		printWriter = new PrintWriter(new BufferedWriter(new FileWriter(
				"Rentals.txt", true)));
		for (RentalModel model : rentalModels) {

			printWriter.append(model.getCustomerModel().getCustomerNumber().toString());
			printWriter.append("#");
			printWriter.append(model.getCustomerModel().getCustomerName());
			printWriter.append("#");
			printWriter.append(model.getVideoCopyModel().getVideoCopyNumber().toString());
			printWriter.append("#");
			printWriter.append(model.getVideoCopyModel().getTitle());
			printWriter.append("#");
			printWriter.append(model.getVideoCopyModel().getPrice().toString());
			printWriter.append("\n");
		}

		printWriter.flush();
		printWriter.close();
	}
}
